# eric7.UI.Browser

Module implementing a browser with class browsing capabilities.

### Global Attributes

None

### Classes

Browser | Class used to display a file system tree.

### Functions

None

## Browser

Class used to display a file system tree.

Via the context menu that is displayed by a right click the user can select various actions on the selected file.

### Signals

binaryFile(filename)
  emitted to open a file as binary (str)
designerFile(filename)
  emitted to open a Qt-Designer file (str)
linguistFile(filename)
  emitted to open a Qt-Linguist (*.ts) file (str)
multiProjectFile(filename)
  emitted to open an eric multi project file (str)
pdfFile(filename)
  emitted to open a PDF file (str)
pixmapEditFile(filename)
  emitted to edit a pixmap file (str)
pixmapFile(filename)
  emitted to open a pixmap file (str)
projectFile(filename)
  emitted to open an eric project file (str)
sourceFile(filename)
  emitted to open a Python file at the first line (str)
sourceFile(filename, lineno)
  emitted to open a Python file at a line (str, int)
sourceFile(filename, lineno, col_offset)
  emitted to open a Python file at a line and column (str, int, int)
sourceFile(filename, lineno, type)
  emitted to open a Python file at a line giving an explicit file type (str, int, str)
sourceFile(filename, linenos)
  emitted to open a Python file giving a list of lines(str, list)
svgFile(filename)
  emitted to open a SVG file (str)
testFile(filename)
  emitted to open a Python file for a unit test (str)
trpreview(filenames)
  emitted to preview Qt-Linguist (*.qm) files (list of str)
trpreview(filenames, ignore)
  emitted to preview Qt-Linguist (*.qm) files indicating whether non-existent files shall be ignored (list of str, bool)
umlFile(filename)
  emitted to open an eric UML file (str)

### Derived from

QTreeView

### Class Attributes

None

### Class Methods

None

### Methods

Browser | Constructor
__addAsToplevelDir | Private slot to handle the Add as top level directory popup menu entry.
__createPopupMenus | Private method to generate the various popup menus.
__deleteDirectory | Private method to delete a directory.
__deleteFile | Private method to delete a file.
__deleteMultiple | Private slot to delete multiple files.
__findInDirectory | Private slot to handle the Find in directory popup menu entry.
__newRemoteTopLevelDir | Private slot to handle the New Remote Top Level Directory popup menu entry.
__newTopLevelDir | Private slot to handle the New Top Level Directory popup menu entry.
__refreshDirectory | Private slot to refresh a directory entry.
__refreshSource | Private slot to refresh the structure of a source file.
__removeToplevel | Private slot to handle the Remove from top level popup menu entry.
__replaceInDirectory | Private slot to handle the Find&Replace in directory popup menu entry.
__showMimeType | Private slot to show the mime type of the selected entry.
_contextMenuRequested | Protected slot to show the context menu of the list view.
_copyToClipboard | Protected method to copy the text shown for an entry to the clipboard.
_deleteFileOrDirectory | Protected slot to delete a directory or file.
_editPixmap | Protected slot to handle the open in icon editor popup menu entry.
_gotoAttribute | Protected slot to handle the selection of the goto menu.
_init | Protected method to perform initialization tasks common to this base class and all derived classes.
_keyboardSearchType | Protected method to check, if the item is of the correct type.
_newDirectory | Protected slot to create a new directory.
_newFile | Protected slot to create a new file.
_openFileInEditor | Protected slot to handle the Open in Editor menu action.
_openHexEditor | Protected slot to handle the open in hex editor popup menu entry.
_openItem | Protected slot to handle the open popup menu entry.
_openPdfViewer | Protected slot to handle the open in PDF viewer popup menu entry.
_resizeColumns | Protected slot to resize the view when items get expanded or collapsed.
_resort | Protected slot to resort the tree.
_showGotoMenu | Protected slot to prepare the goto submenu of the attribute menu.
_showHidden | Protected slot to show or hide hidden files.
_showInFileManager | Protected method to show the selected items path in a file manager application.
getSelectedItems | Public method to get the selected items.
getSelectedItemsCount | Public method to get the count of items selected.
getSelectedItemsCountCategorized | Public method to get a categorized count of selected items.
handleInterpreterChanged | Public slot to handle a change of the debug client's interpreter.
handlePreferencesChanged | Public slot used to handle the preferencesChanged signal.
handleProgramChange | Public slot to handle the programChange signal.
handleTesting | Public slot to handle the testing popup menu entry.
keyboardSearch | Public function to search the tree via the keyboard.
layoutDisplay | Public slot to perform a layout operation.
mouseDoubleClickEvent | Protected method of QAbstractItemView.
saveToplevelDirs | Public slot to save the toplevel directories.
wantedItem | Public method to check type of an item.

### Static Methods

None

#### Browser (Constructor)

Browser(serverInterface, parent=None)

Constructor

serverInterface (EricServerInterface)
  reference to the 'eric-ide' server interface object
parent (QWidget)
  parent widget

#### Browser.__addAsToplevelDir

__addAsToplevelDir()

Private slot to handle the Add as top level directory popup menu entry.

#### Browser.__createPopupMenus

__createPopupMenus()

Private method to generate the various popup menus.

#### Browser.__deleteDirectory

__deleteDirectory(dn)

Private method to delete a directory.

dn (str)
  directory name to be removed from the project

#### Browser.__deleteFile

__deleteFile(fn)

Private method to delete a file.

fn (str)
  filename to be deleted

#### Browser.__deleteMultiple

__deleteMultiple()

Private slot to delete multiple files.

Note: The context menu for multi selection is only shown for file items.

#### Browser.__findInDirectory

__findInDirectory()

Private slot to handle the Find in directory popup menu entry.

#### Browser.__newRemoteTopLevelDir

__newRemoteTopLevelDir()

Private slot to handle the New Remote Top Level Directory popup menu entry.

#### Browser.__newTopLevelDir

__newTopLevelDir()

Private slot to handle the New Top Level Directory popup menu entry.

#### Browser.__refreshDirectory

__refreshDirectory()

Private slot to refresh a directory entry.

#### Browser.__refreshSource

__refreshSource()

Private slot to refresh the structure of a source file.

#### Browser.__removeToplevel

__removeToplevel()

Private slot to handle the Remove from top level popup menu entry.

#### Browser.__replaceInDirectory

__replaceInDirectory()

Private slot to handle the Find&Replace in directory popup menu entry.

#### Browser.__showMimeType

__showMimeType()

Private slot to show the mime type of the selected entry.

#### Browser._contextMenuRequested

_contextMenuRequested(coord)

Protected slot to show the context menu of the list view.

coord (QPoint)
  the position of the mouse pointer

#### Browser._copyToClipboard

_copyToClipboard()

Protected method to copy the text shown for an entry to the clipboard.

#### Browser._deleteFileOrDirectory

_deleteFileOrDirectory()

Protected slot to delete a directory or file.

#### Browser._editPixmap

_editPixmap()

Protected slot to handle the open in icon editor popup menu entry.

#### Browser._gotoAttribute

_gotoAttribute(act)

Protected slot to handle the selection of the goto menu.

act (EricAction)
  reference to the action

#### Browser._init

_init()

Protected method to perform initialization tasks common to this base class and all derived classes.

#### Browser._keyboardSearchType

_keyboardSearchType(item)

Protected method to check, if the item is of the correct type.

item (BrowserItem)
  reference to the item

Return:
  flag indicating a correct type

Return Type:
  bool

#### Browser._newDirectory

_newDirectory()

Protected slot to create a new directory.

#### Browser._newFile

_newFile()

Protected slot to create a new file.

#### Browser._openFileInEditor

_openFileInEditor()

Protected slot to handle the Open in Editor menu action.

#### Browser._openHexEditor

_openHexEditor()

Protected slot to handle the open in hex editor popup menu entry.

#### Browser._openItem

_openItem()

Protected slot to handle the open popup menu entry.

#### Browser._openPdfViewer

_openPdfViewer()

Protected slot to handle the open in PDF viewer popup menu entry.

#### Browser._resizeColumns

_resizeColumns()

Protected slot to resize the view when items get expanded or collapsed.

#### Browser._resort

_resort()

Protected slot to resort the tree.

#### Browser._showGotoMenu

_showGotoMenu()

Protected slot to prepare the goto submenu of the attribute menu.

#### Browser._showHidden

_showHidden(checked)

Protected slot to show or hide hidden files.

checked (bool)
  flag indicating the state of the action

#### Browser._showInFileManager

_showInFileManager()

Protected method to show the selected items path in a file manager application.

#### Browser.getSelectedItems

getSelectedItems(filterList=None)

Public method to get the selected items.

filterList (list of Class)
  list of classes to check against

Return:
  list of selected items

Return Type:
  list of BrowserItem

#### Browser.getSelectedItemsCount

getSelectedItemsCount(filterList=None)

Public method to get the count of items selected.

filterList (list of Class)
  list of classes to check against

Return:
  count of items selected

Return Type:
  int

#### Browser.getSelectedItemsCountCategorized

getSelectedItemsCountCategorized(filterList=None)

Public method to get a categorized count of selected items.

filterList (list of Class)
  list of classes to check against

Return:
  a dictionary containing the counts of items belonging to the individual filter classes. The keys of the dictionary are the string representation of the classes given in the filter (i.e. str(filterClass)). The dictionary contains an additional entry with key "sum", that stores the sum of all selected entries fulfilling the filter criteria.

Return Type:
  dict

#### Browser.handleInterpreterChanged

handleInterpreterChanged(interpreter)

Public slot to handle a change of the debug client's interpreter.

interpreter (str)
  interpreter of the debug client

#### Browser.handlePreferencesChanged

handlePreferencesChanged()

Public slot used to handle the preferencesChanged signal.

#### Browser.handleProgramChange

handleProgramChange(fn)

Public slot to handle the programChange signal.

fn (str)
  file name

#### Browser.handleTesting

handleTesting()

Public slot to handle the testing popup menu entry.

#### Browser.keyboardSearch

keyboardSearch(search)

Public function to search the tree via the keyboard.

search (str)
  the character entered via the keyboard

#### Browser.layoutDisplay

layoutDisplay()

Public slot to perform a layout operation.

#### Browser.mouseDoubleClickEvent

mouseDoubleClickEvent(mouseEvent)

Protected method of QAbstractItemView.

Reimplemented to disable expanding/collapsing of items when double-clicking. Instead the double-clicked entry is opened.

mouseEvent (QMouseEvent)
  the mouse event

#### Browser.saveToplevelDirs

saveToplevelDirs()

Public slot to save the toplevel directories.

#### Browser.wantedItem

wantedItem(itm, filterList=None)

Public method to check type of an item.

itm (BrowserItem)
  the item to check
filterList (list of Class)
  list of classes to check against

Return:
  flag indicating item is a valid type

Return Type:
  bool

Up